﻿using Org.BouncyCastle.Asn1.X9;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

namespace DetectApp
{
    public class GlobalData
    {
        private static GlobalData? _instance;

        public RatioParam? RatioParam { get; set; }
        public static GlobalData Instance
        {
            get
            {
                _instance ??= new GlobalData();
                return _instance;
            }
        }
        private GlobalData()
        {
            var filepath = $"Products//ratioParam.json";
            if (File.Exists(filepath))
            {
                using var stream = new FileStream(filepath, FileMode.Open, FileAccess.Read);
                RatioParam = JsonSerializer.Deserialize<RatioParam>(stream) ?? new();
            }
            else
            {
                RatioParam = new RatioParam();
            }
        }
    }
}
